package com.boarsoft.boar.soagov.app.action;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.boarsoft.bean.LogonI;
import com.boarsoft.bean.ReplyInfo;
import com.boarsoft.boar.app.AppBiz;
import com.boarsoft.boar.soagov.entity.AppSoagovInfo;
import com.boarsoft.boar.soagov.entity.ProtocolInfo;
import com.boarsoft.common.Authorized;
import com.boarsoft.common.dao.PagedResult;
import com.boarsoft.web.login.Logined;

/**
 * 暂未使用
 * 
 * @author Mac_J
 *
 */
@RestController
@RequestMapping("/app/protocol")
public class AppProtocolAction {
	@Autowired
	private AppBiz appBiz;

	/**
	 * TODO 查询指定的应用所支持的协议
	 * 
	 * @return
	 */
	@RequestMapping("/list.do")
	@Authorized(code = "app.protocol.list")
	public ReplyInfo<Object> list(@Logined LogonI<String> logon, String appId) {
		AppSoagovInfo o = (AppSoagovInfo) appBiz.get(appId);
		List<ProtocolInfo> lt = new ArrayList<>(o.getProtocols());
		return new ReplyInfo<Object>(true, new PagedResult<ProtocolInfo>(lt.size(), lt, 1, 20));
	}

	/**
	 * TODO 删除应用与协议的关系
	 * 
	 * @return
	 */
	@RequestMapping("/delete")
	@Authorized(code = "app.protocol.delete")
	public ReplyInfo<Object> delete(String id) {
		// appProtocolBiz.delete(id);
		return ReplyInfo.SUCCESS;
	}
}